package com.dkm.ou.me.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ou.me.domain.Role;
import com.dkm.ou.me.persistence.dao.RoleQueryDao;
import com.dkm.ou.me.persistence.entity.ExportRolePo;
import com.dkm.ou.me.persistence.entity.RolePo;
import com.dkm.ou.me.repository.RoleRepository;

/**
 * 对象功能:角色 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:颜超敏
 * 创建时间:2014-12-12 11:01:12
 */
@Repository
public class RoleRepositoryImpl extends AbstractRepository<String, RolePo,Role> implements RoleRepository{
	  
	@Resource
	private  RoleQueryDao roleQueryDao;

	public Role newInstance() {
		RolePo po = new RolePo();
		Role role = SpringHelper.getBean(Role.class);
		role.setData(po);
		return role;
	}

	public Role newInstance(RolePo po) {
		Role role = SpringHelper.getBean(Role.class);
		role.setData(po);
		return role;
	} 
	
	@Override
	protected IQueryDao<String, RolePo> getQueryDao() {
		return roleQueryDao;
	}

	@Override
	public List<RolePo> findByUserIds(String userId) {
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("userId", userId);
		return roleQueryDao.findByKey("findByUserIds", params);
	}
	
	@Override
	public List<ExportRolePo> getRoleExport(String whereSql) {
		return roleQueryDao.getRoleExport(whereSql);
	}
}
